/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.jrill;

import java.io.Serializable;
import java.util.Date;
import org.apache.commons.lang.StringUtils;

/**
 *
 * @author K.Waga
 */
public abstract class AbstractActivity implements Activity, Serializable {
    
    private static final long serialVersionUID = -288127540187468336L;

    private Long id;
    /**
     * some note on activity status change
     */
    private String note;
    private String organization;
    private Participant owner;
    private boolean parallel;
    /**
     * indicate if the activity is parallel activity
     */
    private Date processed;
    private String role;
    private Long version;
    /**
     * workflow this activity belongs
     */
    private SimpleWorkflow workflow;
    private Date dueDate;
    private String notificationGroup;
    private String activityGroup;
    private int quorum;
    private boolean finished;

    /**
     * @return the dueDate
     */
    public Date getDueDate() {
        return dueDate;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the note
     */
    public String getNote() {
        return note;
    }

    /**
     * @return the organization
     */
    public String getOrganization() {
        return organization;
    }

    /**
     * @return the owner
     */
    public Participant getOwner() {
        return owner;
    }

    /**
     * @return the processed
     */
    public Date getProcessed() {
        return processed;
    }
    
    /**
     * @return the parallel
     */
    public boolean isParallel() {
        return parallel || !StringUtils.isBlank(getActivityGroup()); //non blank activity group implies activity itself as parallel
    }
    /**
     * @return the role
     */
    public String getRole() {
        return role;
    }

    /**
     * @return the version
     */
    public Long getVersion() {
        return version;
    }

    /**
     * @return the workflow
     */
    public SimpleWorkflow getWorkflow() {
        return workflow;
    }

    /**
     * Returns whether this activity has been processed.
     * @return
     */
    /**
     * Returns whether this activity has been processed.
     * @return
     */
    public boolean isProcessed() {
        return null != getProcessed();
    }

    /**
     * @param dueDate the dueDate to set
     */
    public void setDueDate(Date dueDate) {
        this.dueDate = dueDate;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param note the note to set
     */
    public void setNote(String note) {
        this.note = note;
    }

    /**
     * @param organization the organization to set
     */
    public void setOrganization(String organization) {
        this.organization = organization;
    }

    /**
     * @param owner the owner to set
     */
    public void setOwner(Participant owner) {
        this.owner = owner;
    }

    /**
     * @param parallel the parallel to set
     */
    /**
     * @param parallel the parallel to set
     */
    public void setParallel(boolean parallel) {
        this.parallel = parallel;
    }

    /**
     * Set processed date of activity.
     * When non-null date is provided, sets finished = true. When null date is provided, sets finished = false.
     * @param processed the processed to set
     */
    public void setProcessed(Date processed) {
        this.processed = processed;
        if (processed != null) {
            setFinished(true);
        } else {
            setFinished(false);
        }
    }

    /**
     * @param role the role to set
     */
    public void setRole(String role) {
        this.role = role;
    }

    /**
     * @param version the version to set
     */
    public void setVersion(Long version) {
        this.version = version;
    }

    /**
     * @param workflow the workflow to set
     */
    public void setWorkflow(SimpleWorkflow workflow) {
        this.workflow = workflow;
    }

    /**
     * @return the notificationGroup
     */
    public String getNotificationGroup() {
        return notificationGroup;
    }

    /**
     * @param notificationGroup the notificationGroup to set
     */
    public void setNotificationGroup(String notificationGroup) {
        this.notificationGroup = notificationGroup;
    }

    /**
     * @return the activityGroup
     */
    public String getActivityGroup() {
        return activityGroup;
    }

    /**
     * @param activityGroup the activityGroup to set
     */
    public void setActivityGroup(String activityGroup) {
        this.activityGroup = activityGroup;
    }

    /**
     * @return the quorum
     */
    public int getQuorum() {
        return quorum;
    }

    /**
     * @param quorum the quorum to set
     */
    public void setQuorum(int quorum) {
        this.quorum = quorum;
    }
    /**
     * 
     * @return 
     */
    public boolean isFinished() {
        return finished;
    }
    /**
     * 
     * @param finished 
     */
    public void setFinished(boolean finished) {
        this.finished = finished;
    }

    
}
